﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Pages/admin/list_view.master" %>

<script runat="server">
    void Page_Init(object o, EventArgs e)
    {
        if (null != Session["RoleID"])
        {
            ds2.FilterExpression = string.Format("RoleID={0}", Session["RoleID"]);
        }
        else
        {
            ds2.FilterExpression = string.Format("RoleID={0}", 0);
        }
        if (!IsPostBack)
        {
            ds2.FilterExpression = string.Format("RoleID={0}", 0);
        }
    }
    
    void clickme(object o, EventArgs e)
    {
        //System.Threading.Thread.Sleep(5000);
       // mylabel.Text = "click alrady";
       // timerbox.Text = DateTime.Now.ToString();
        
    }

    void MakeChanged(Object sender,  EventArgs e)
    {
        ASPxGridView grid = sender as ASPxGridView;

        int t = grid.FocusedRowIndex;
        if (t > -1)
        {
            object id = grid.GetRowValues(t, new string[] { "RoleID" });
            //object name = grid.GetRowValues(t, new string[] { "Name" });
            // mylabel.Text = "Selection:" + id.ToString();
            
            Session["RoleID"] = id;
            int idn = int.Parse(id.ToString());
            if (idn > 0)
            {

            } 
            
            ds2.FilterExpression = string.Format("RoleID={0}", Session["RoleID"]);

            grid2.Selection.UnselectAll();
            grid2.PageIndex = 0;
            grid2.DataBind();
            
            
            
            
            //this.dsXXModel.FilterExpression = "RoleID=" + o;
            //DataBind();
        }
    }


    protected void grid2_Init(object sender, EventArgs e)
    {
        ASPxGridView grd = sender as ASPxGridView;
        if (grd != null)
        {
            grd.ForceDataRowType(typeof(Touchmax.AcAccess));
        }
    }

    protected void grid2_InitNewRow(object sender, DevExpress.Web.Data.ASPxDataInitNewRowEventArgs e)
    {
    }

    protected void grid2_RowUpdating(object sender, DevExpress.Web.Data.ASPxDataUpdatingEventArgs e)
    {
    }

    protected void grid2_RowInserting(object sender, DevExpress.Web.Data.ASPxDataInsertingEventArgs e)
    {
        int id = int.Parse(Session["RoleID"].ToString());
        e.NewValues["RoleID"] = id;
    }

    
    </script>

<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
    <style>
    div {font-size:10px;font-family:Verdana;}
    </style>
    <script type="text/javascript">
    </script>
</asp:Content>

<asp:Content ID="title1" ContentPlaceHolderID="Title1" Runat="Server">
<table width=100% cellpadding="4">
    <tr>
    <td align=left class="bb">
        User Role List
    </td>
    <td align=right class="bb">
    </td>
    </tr>
</table>
</asp:Content>
<asp:Content ID="title2" ContentPlaceHolderID="Title2" Runat="Server">
<table width=100% cellpadding="4">
    <tr>
    <td align=left class="bb">
        Access Rights Setup
    </td>
    <td align=right class="bb">
    </td>
    </tr>
</table>
</asp:Content>
<asp:Content ID="title3" ContentPlaceHolderID="Title3" Runat="Server">

</asp:Content>

<asp:Content ID="Page1" ContentPlaceHolderID="Page1" Runat="Server">
<wilson:DataSource ID="ds1" TypeName="Touchmax.AcRole" KeyMember="RoleID" FilterExpression="1=1" runat="server" ObjectSpace="Touchmax.Manager.ORManager"/>
<dxwgv:ASPxGridView ID="grid1" ClientInstanceName="grid1" runat="server" DataSourceID="ds1" KeyFieldName="RoleID" 
       OnFocusedRowChanged="MakeChanged" Width="100%" AutoGenerateColumns="False" EnableCallBacks="False">
                <SettingsPager Mode="ShowAllRecords"/>
                <Columns>
                    <dxwgv:GridViewDataColumn FieldName="RoleName" VisibleIndex="1" SortIndex="1" SortOrder="Ascending">
                    </dxwgv:GridViewDataColumn>
                </Columns>
                <Settings ShowGroupPanel="False" ShowFooter="False" ShowTitlePanel="false" ShowColumnHeaders="False" />
                <SettingsBehavior AllowMultiSelection="false" AllowFocusedRow="true" ProcessFocusedRowChangedOnServer="true" />
            </dxwgv:ASPxGridView>
</asp:Content>
<asp:Content ID="Page2" ContentPlaceHolderID="Page2" Runat="Server">
<wilson:DataSource ID="dsBranch" TypeName="Touchmax.BoBranch" KeyMember="RoleID" FilterExpression="1=1" runat="server" ObjectSpace="Touchmax.Manager.ORManager"/>

<wilson:DataSource ID="dsRole" TypeName="Touchmax.AcRole" KeyMember="RoleID" FilterExpression="1=1" runat="server" ObjectSpace="Touchmax.Manager.ORManager"/>
<wilson:DataSource ID="dsObject" TypeName="Touchmax.AcObject" KeyMember="ObjectID" FilterExpression="1=1" runat="server" ObjectSpace="Touchmax.Manager.ORManager"/>
<wilson:DataSource ID="ds2" TypeName="Touchmax.AcAccess" KeyMember="AccessID" FilterExpression="RoleID=0" runat="server" ObjectSpace="Touchmax.Manager.ORManager"/>
<dxwgv:ASPxGridView ID="grid2" ClientInstanceName="grid2" runat="server" DataSourceID="ds2" KeyFieldName="AccessID" 
        Width="100%" AutoGenerateColumns="False"  EnableCallBacks="False" OnInit="grid2_Init" OnInitNewRow="grid2_InitNewRow" OnRowUpdating="grid2_RowUpdating" OnRowInserting="grid2_RowInserting">
                <SettingsPager Mode="ShowAllRecords"/>
                <Columns>
                    <dxwgv:GridViewCommandColumn VisibleIndex="0" Width="80">
                        <EditButton Visible="True" />
                    </dxwgv:GridViewCommandColumn>           
                    <dxwgv:GridViewDataComboBoxColumn Caption="Feature"  ReadOnly="true" FieldName="ObjectID" VisibleIndex="1">
                        <PropertiesComboBox DataSourceID="dsObject" TextField="ObjectName" ValueField="ObjectID" EnableSynchronization="False"  EnableIncrementalFiltering="True"></PropertiesComboBox>
                    </dxwgv:GridViewDataComboBoxColumn>         
                    <dxwgv:GridViewDataComboBoxColumn Caption="Read" FieldName="CanRead" VisibleIndex="2">
                        <PropertiesComboBox EnableSynchronization="False"  EnableIncrementalFiltering="True">
                            <Items>
                                <dxe:ListEditItem Text="None" Value="None" />
                                <dxe:ListEditItem Text="Local" Value="Local"  />
                                <dxe:ListEditItem Text="Team" Value="Team" />
                                <dxe:ListEditItem Text="Branch" Value="Branch" />
                                <dxe:ListEditItem Text="Global" Value="Global" />
                            </Items>
                        </PropertiesComboBox>
                    </dxwgv:GridViewDataComboBoxColumn>         
                    <dxwgv:GridViewDataComboBoxColumn Caption="Write" FieldName="CanWrite" VisibleIndex="3">
                        <PropertiesComboBox EnableSynchronization="False"  EnableIncrementalFiltering="True">
                            <Items>
                                <dxe:ListEditItem Text="None" Value="None" />
                                <dxe:ListEditItem Text="Local" Value="Local"  />
                                <dxe:ListEditItem Text="Team" Value="Team" />
                                <dxe:ListEditItem Text="Branch" Value="Branch" />
                                <dxe:ListEditItem Text="Global" Value="Global" />
                            </Items>
                        </PropertiesComboBox>
                    </dxwgv:GridViewDataComboBoxColumn>         
                    <dxwgv:GridViewDataComboBoxColumn Caption="Append" FieldName="CanAppend" VisibleIndex="4">
                        <PropertiesComboBox EnableSynchronization="False"  EnableIncrementalFiltering="True">
                            <Items>
                                <dxe:ListEditItem Text="None" Value="None" />
                                <dxe:ListEditItem Text="Local" Value="Local"  />
                                <dxe:ListEditItem Text="Team" Value="Team" />
                                <dxe:ListEditItem Text="Branch" Value="Branch" />
                                <dxe:ListEditItem Text="Global" Value="Global" />
                            </Items>
                        </PropertiesComboBox>
                    </dxwgv:GridViewDataComboBoxColumn>         
                    <dxwgv:GridViewDataComboBoxColumn Caption="Delete" FieldName="CanDelete" VisibleIndex="5">
                        <PropertiesComboBox EnableSynchronization="False"  EnableIncrementalFiltering="True">
                            <Items>
                                <dxe:ListEditItem Text="None" Value="None" />
                                <dxe:ListEditItem Text="Local" Value="Local"  />
                                <dxe:ListEditItem Text="Team" Value="Team" />
                                <dxe:ListEditItem Text="Branch" Value="Branch" />
                                <dxe:ListEditItem Text="Global" Value="Global" />
                            </Items>
                        </PropertiesComboBox>
                    </dxwgv:GridViewDataComboBoxColumn>         
                    </Columns>
                    <SettingsEditing Mode="Inline" />
      
                <Settings ShowGroupPanel="False" ShowFooter="False" ShowTitlePanel="false" ShowColumnHeaders="true" />
                <SettingsBehavior ConfirmDelete="True" AllowFocusedRow="true" ProcessFocusedRowChangedOnServer="true" />
            </dxwgv:ASPxGridView>
</asp:Content>
<asp:Content ID="Page3" ContentPlaceHolderID="Page3" Runat="Server">
</asp:Content>

